import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:finance_app/src/widgets/select/mixin/check_box_mixin.dart';
import 'package:finance_app/src/widgets/select/mixin/radio_mixin.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

class InvoiceNumberRadio = InvoiceNumberCheckBox with RadioMixin;

class InvoiceNumberCheckBox extends StatelessWidget with CheckBoxMixin {
  final bool isSelect;
  final bool isEnable;

  final String title;
  final String unit;
  final double amount;
  final String due;
  final String billNumber;
  final String status;

  const InvoiceNumberCheckBox({
    Key key,
    this.isSelect = false,
    this.isEnable = true,
    this.title,
    this.unit,
    this.amount,
    this.due,
    this.billNumber,
    this.status,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
        left: getDp(29),
        right: getDp(19),
        top: getDp(23),
        bottom: getDp(23),
      ),
      decoration: BoxDecoration(
          color: isSelect == true ? aceSelectBackgroundColor : Colors.white,
          border: Border(
              bottom: BorderSide(
            color: aceWhiteGreyColor,
            width: getDp(0.5),
          ))),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          buildSelectWidget,
          SizedBox(
            width: getDp(24),
          ),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w700,
                    height: 1,
                  ),
                ),
                AppSpaces.h6,
                Text(
                  'Invoice No: #$billNumber',
                  style: TextStyle(
                    color: aceDarkGrayColor,
                    fontSize: getSp(14),
                    fontWeight: FontWeight.w400,
                    height: 1,
                  ),
                ),
                AppSpaces.h6,
                Text(
                  'Due: $due',
                  style: TextStyle(
                    color: aceDarkGrayColor,
                    fontSize: getSp(14),
                    fontWeight: FontWeight.w400,
                    height: 1,
                  ),
                ),
              ],
            ),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              if (status != null)
                Container(
                  margin: EdgeInsets.only(
                    bottom: getDp(10),
                  ),
                  child: status == 'Overdue'
                      ? RedTagWidget(
                          content: status,
                        )
                      : NormalRedTagWidget(
                          content: status,
                        ),
                ),
              Text.rich(TextSpan(children: [
                TextSpan(
                  text: '${CashUtils.operation(amount)}',
                  style: TextStyle(
                    fontSize: getSp(16),
                    color: CashUtils.getColor(amount),
                    fontWeight: FontWeight.bold,
                    height: 14 / 12,
                  ),
                ),
                TextSpan(
                  text: '$unit ${CashUtils.ignoreFormatCashAmount(amount)}',
                  style: TextStyle(
                    color: aceBlackColor,
                    fontSize: getSp(16),
                    fontWeight: FontWeight.w700,
                    height: 14 / 16,
                  ),
                ),
              ])),
            ],
          ),
        ],
      ),
    );
  }
}
